Skip to content

fix: handle file_path=None in MSGToDocument - #13793

Open
Karthik-beta wants to merge 3 commits into
deepset-ai:mainfrom
Karthik-beta:fix/msg-null-file-path
Open

Karthik-beta wants to merge 3 commits into
deepset-ai:mainfrom
Karthik-beta:fix/msg-null-file-path

Conversation

@Karthik-beta

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

MSGToDocument no longer crashes when a ByteStream has file_path=None in its meta. It now uses the same check as the other converters (bytestream.meta.get("file_path")), so None is kept in the document meta instead of being passed to os.path.basename.

Same fix as #13765 for XLSXToDocument.

How did you test it?

  • Added a test that converts a .msg ByteStream with file_path=None. It fails on main with the TypeError and passes with this change.
  • hatch run test:unit test/components/converters/test_msg_to_document.py: 8 passed.
  • hatch run test:types on the changed files and ruff check / ruff format --check: clean.

Notes for the reviewer

Small change. Nothing changes when file_path is a real path or missing.

This PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@Karthik-beta
Karthik-beta requested a review from a team as a code owner November 17, 2026 16:09
@Karthik-beta
Karthik-beta requested review from sjrl and removed request for a team November 17, 2026 16:09
@vercel

vercel Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

@Karthik-beta is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/converters
  msg.py
  haystack/core/pipeline
  pipeline.py
Project Total  

This report was generated by python-coverage-comment-action

1AbdullahButt

This comment was marked as spam.

@Karthik-beta

Copy link
Copy Markdown
Contributor Author

Thanks for checking all the converters, @1AbdullahButt! I went with your first option and added an assertion that parent_file_path is None for attachments. I left the behaviour as it is, so it stays the same as the XLSX fix in #13765, where None is kept in the meta.

assert result["attachments"][0].meta == {"date_added": "2021-09-01T00:00:00", "file_path": "sample_pdf_1.pdf"}
assert "parent_file_path" not in result["attachments"][0].meta

def test_run_bytestream_with_null_file_path(self, test_files_path):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets parametrize test_run_bytestream_without_file_path over meta={} and meta={"file_path": None} instead of adding a new test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks! test_run_bytestream_without_file_path is now parametrized over meta={} and meta={"file_path": None}, and the separate test is gone. One detail: I switched it from store_full_path=True to the default. With True, the basename call that crashed never runs, so the None case would not catch the bug.

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Nov 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSGToDocument raises TypeError when a ByteStream has file_path=None

3 participants